package pl.edu.pw.stud.ltrzaska.report;

import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import org.apache.log4j.Logger;

import pl.edu.pw.stud.ltrzaska.logic.PolicyViolation;

public class ReportGenerator {
	private static Logger LOGGER = Logger.getLogger(ReportGenerator.class);

	public void generate(List<PolicyViolation> policyViolations, IReportFormatter rf, String outFile) {
		String report = rf.format(policyViolations);
		
		LOGGER.debug("Writing repot to: " + outFile);
		LOGGER.debug("REPORT: " + report);
		
		PrintWriter out = null;
		try {
			out = new PrintWriter(new FileWriter(outFile));
			out.write(report);
		} catch (IOException e) {
			LOGGER.error("Blad zapisu do pliku raportu");
		} finally {
			out.close();
		}
	}
}
